﻿using LJX.SmartPark.Common.ResponseOutput;
using LJX.SmartPark.Service.StudentServices;
using LJX.SmartPark.Service.StudentServices.Dto;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace LJX.SmartPark.WebApi.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    [ApiExplorerSettings(GroupName = "SD")]
    public class StudentController : ControllerBase
    {
        private readonly IStudentService _studentService;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="studentService"></param>
        public StudentController(IStudentService studentService)
        {
            _studentService = studentService;
        }

        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<Response<bool>> PostAddStudent(StudentInput input)
        {
            var result = _studentService.PostAddStudent(input);
            return result;
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="input"></param>
        [HttpDelete]
        public Task<Response<bool>> DeleteStudent(StudentInput input)
        {
            var result = _studentService.DeleteByIdAsync(input);
            return result;
        }

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPut]
        public Task<Response<bool>> PutUpdateStudent(StudentInput input)
        {
            var result = _studentService.PutUpdateStudent(input);

            return result;

        }




        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public Response<List<StudentInput>> GetStudentList(StudentInput input)
        {
            var result = _studentService.GetStudentListAsync(input);
            return result.Result;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [ApiExplorerSettings(GroupName = "XM")]
        [HttpPost]
        public Response<StudentInput> GetStudentById(StudentInput input)
        {
            var student = _studentService.GetStudentById(input);
            return student;
        }

    }
}
